using SqlSugar;
using System.ComponentModel.DataAnnotations;

namespace Rabbit3.Api.Models
{
    /// <summary>
    /// 企业信息表
    /// </summary>
    [SugarTable("enterprise_info")]
    public class EnterpriseInfo
    {
        /// <summary>
        /// 主键ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }

        /// <summary>
        /// 溯源信息ID
        /// </summary>
        [SugarColumn(IsNullable = false)]
        [Required(ErrorMessage = "溯源信息ID不能为空")]
        public int TraceabilityId { get; set; }

        /// <summary>
        /// 企业阶段类型 (养殖/屠宰/深加工)
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(20)", IsNullable = false)]
        [Required(ErrorMessage = "企业阶段类型不能为空")]
        [StringLength(20, ErrorMessage = "企业阶段类型长度不能超过20个字符")]
        public string StageType { get; set; } = string.Empty;

        /// <summary>
        /// 关联信息ID (养殖信息ID/屠宰信息ID/深加工信息ID)
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? RelatedInfoId { get; set; }

        /// <summary>
        /// 公司名称
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(100)", IsNullable = false)]
        [Required(ErrorMessage = "公司名称不能为空")]
        [StringLength(100, ErrorMessage = "公司名称长度不能超过100个字符")]
        public string CompanyName { get; set; } = string.Empty;

        /// <summary>
        /// 生产许可证号
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(50)", IsNullable = false)]
        [Required(ErrorMessage = "生产许可证号不能为空")]
        [StringLength(50, ErrorMessage = "生产许可证号长度不能超过50个字符")]
        public string ProductionLicenseNumber { get; set; } = string.Empty;

        /// <summary>
        /// 公司地址
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(200)", IsNullable = true)]
        [StringLength(200, ErrorMessage = "公司地址长度不能超过200个字符")]
        public string? CompanyAddress { get; set; }

        /// <summary>
        /// 成立时间
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public DateTime? EstablishmentDate { get; set; }

        /// <summary>
        /// 公司简介
        /// </summary>
        [SugarColumn(ColumnDataType = "text", IsNullable = true)]
        public string? CompanyProfile { get; set; }

        /// <summary>
        /// 企业照片URL
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(500)", IsNullable = true)]
        [StringLength(500, ErrorMessage = "企业照片URL长度不能超过500个字符")]
        public string? EnterprisePhotoUrl { get; set; }

        /// <summary>
        /// 动检证URL
        /// </summary>
        [SugarColumn(ColumnDataType = "varchar(500)", IsNullable = true)]
        [StringLength(500, ErrorMessage = "动检证URL长度不能超过500个字符")]
        public string? AnimalQuarantineCertificateUrl { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime CreatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public DateTime UpdatedAt { get; set; } = DateTime.Now;

        /// <summary>
        /// 是否删除
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public bool IsDeleted { get; set; } = false;

        /// <summary>
        /// 创建人ID
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? CreatedBy { get; set; }

        /// <summary>
        /// 更新人ID
        /// </summary>
        [SugarColumn(IsNullable = true)]
        public int? UpdatedBy { get; set; }

        /// <summary>
        /// 导航属性 - 溯源信息
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public TraceabilityInfo? TraceabilityInfo { get; set; }
    }
}


